﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace BabyShop.WebSite.Models
{
    [Table("ProductTypes")]
    public class ProductType
    {
        [Key]
        public Guid ProductTypeGuid { get; set; }

        [Display(Name = "类型名称")]
        [StringLength(12)]
        [Required(AllowEmptyStrings = false)]
        public string ProductTypeName { get; set; }

        public int MenuTypeInt { get; set; }

        [Display(Name = "菜单类型")]
        public MenuType MenuType {
            get { return (MenuType)MenuTypeInt; }
            set { MenuTypeInt = (int)value; } 
        }

        [Display(Name = "自定义地址")]
        [StringLength(255)]
        public string MenuUrl { get; set; }

        [Display(Name = "上级类型")]
        public Guid? ParentGuid { get; set; }

        public CommonColumns CommonColumns { get; set; }

        [ForeignKey("ParentGuid")]
        public virtual ProductType ParentProductType { get; set; }

        public virtual ICollection<ProductType> ChildProductTypes { get; set; }

        public virtual ICollection<Product> Products { get; set; } 
    }

    public enum MenuType
    {
        NormalType,
        CategoryType
    }
}